﻿
namespace UsingNonMVVMElements.Command
{
    using System;
    using System.Windows.Input;
    using System.Windows.Controls;

    class GoBackCommand : ICommand
    {
        public bool CanExecute(object parameter)
        {         
            bool ret = true;

            //if (parameter is WebBrowser)
            //{
            //    WebBrowser browser = (WebBrowser)parameter;
            //    ret = browser.CanGoBack;
            //}
            if (parameter != null && parameter is bool)
            {
                ret = (bool)parameter;
            }

            return ret;
        }

        //public event EventHandler CanExecuteChanged;
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }


        public void Execute(object parameter)
        {
            if (parameter is WebBrowser)
            {
                //WebBrowser browser = (WebBrowser)parameter;
                //browser.GoBack();
            }
        }
    }
}
